import 'package:gold/generated/json/base/json_convert_content.dart';
import 'package:gold/model/review_list_model.dart';

ReviewListModel $ReviewListModelFromJson(Map<String, dynamic> json) {
  final ReviewListModel reviewListModel = ReviewListModel();
  final List<ReviewModel>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<ReviewModel>(e) as ReviewModel).toList();
  if (data != null) {
    reviewListModel.data = data;
  }
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    reviewListModel.total = total;
  }
  final int? count = jsonConvert.convert<int>(json['count']);
  if (count != null) {
    reviewListModel.count = count;
  }
  final int? perPage = jsonConvert.convert<int>(json['per_page']);
  if (perPage != null) {
    reviewListModel.perPage = perPage;
  }
  final int? currentPage = jsonConvert.convert<int>(json['current_page']);
  if (currentPage != null) {
    reviewListModel.currentPage = currentPage;
  }
  final int? totalPages = jsonConvert.convert<int>(json['total_pages']);
  if (totalPages != null) {
    reviewListModel.totalPages = totalPages;
  }
  return reviewListModel;
}

Map<String, dynamic> $ReviewListModelToJson(ReviewListModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['data'] = entity.data?.map((v) => v.toJson()).toList();
  data['total'] = entity.total;
  data['count'] = entity.count;
  data['per_page'] = entity.perPage;
  data['current_page'] = entity.currentPage;
  data['total_pages'] = entity.totalPages;
  return data;
}

extension ReviewListModelExtension on ReviewListModel {
  ReviewListModel copyWith({
    List<ReviewModel>? data,
    int? total,
    int? count,
    int? perPage,
    int? currentPage,
    int? totalPages,
  }) {
    return ReviewListModel()
      ..data = data ?? this.data
      ..total = total ?? this.total
      ..count = count ?? this.count
      ..perPage = perPage ?? this.perPage
      ..currentPage = currentPage ?? this.currentPage
      ..totalPages = totalPages ?? this.totalPages;
  }
}

ReviewModel $ReviewModelFromJson(Map<String, dynamic> json) {
  final ReviewModel reviewModel = ReviewModel();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    reviewModel.id = id;
  }
  final int? userId = jsonConvert.convert<int>(json['user_id']);
  if (userId != null) {
    reviewModel.userId = userId;
  }
  final int? rating = jsonConvert.convert<int>(json['rating']);
  if (rating != null) {
    reviewModel.rating = rating;
  }
  final int? isPrivate = jsonConvert.convert<int>(json['is_private']);
  if (isPrivate != null) {
    reviewModel.isPrivate = isPrivate;
  }
  final String? comment = jsonConvert.convert<String>(json['comment']);
  if (comment != null) {
    reviewModel.comment = comment;
  }
  final String? images = jsonConvert.convert<String>(json['images']);
  if (images != null) {
    reviewModel.images = images;
  }
  final MemberModel? member = jsonConvert.convert<MemberModel>(json['member']);
  if (member != null) {
    reviewModel.member = member;
  }
  return reviewModel;
}

Map<String, dynamic> $ReviewModelToJson(ReviewModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['user_id'] = entity.userId;
  data['rating'] = entity.rating;
  data['is_private'] = entity.isPrivate;
  data['comment'] = entity.comment;
  data['images'] = entity.images;
  data['member'] = entity.member?.toJson();
  return data;
}

extension ReviewModelExtension on ReviewModel {
  ReviewModel copyWith({
    int? id,
    int? userId,
    int? rating,
    int? isPrivate,
    String? comment,
    String? images,
    MemberModel? member,
  }) {
    return ReviewModel()
      ..id = id ?? this.id
      ..userId = userId ?? this.userId
      ..rating = rating ?? this.rating
      ..isPrivate = isPrivate ?? this.isPrivate
      ..comment = comment ?? this.comment
      ..images = images ?? this.images
      ..member = member ?? this.member;
  }
}

MemberModel $MemberModelFromJson(Map<String, dynamic> json) {
  final MemberModel memberModel = MemberModel();
  final int? uid = jsonConvert.convert<int>(json['uid']);
  if (uid != null) {
    memberModel.uid = uid;
  }
  final String? nickname = jsonConvert.convert<String>(json['nickname']);
  if (nickname != null) {
    memberModel.nickname = nickname;
  }
  final String? avatar = jsonConvert.convert<String>(json['avatar']);
  if (avatar != null) {
    memberModel.avatar = avatar;
  }
  return memberModel;
}

Map<String, dynamic> $MemberModelToJson(MemberModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['uid'] = entity.uid;
  data['nickname'] = entity.nickname;
  data['avatar'] = entity.avatar;
  return data;
}

extension MemberModelExtension on MemberModel {
  MemberModel copyWith({
    int? uid,
    String? nickname,
    String? avatar,
  }) {
    return MemberModel()
      ..uid = uid ?? this.uid
      ..nickname = nickname ?? this.nickname
      ..avatar = avatar ?? this.avatar;
  }
}